package comchifaner.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class PropertyUtil {
	
	private static Properties properties;
	static{
		properties = new Properties();
		InputStream inputstream = PropertyUtil.class.getResourceAsStream("/conf/config.properties");
		try {
			properties.load(inputstream);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				inputstream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static String getString(String key){
		return properties.getProperty(key, null);
	}
	
	public static int getInt(String key){
		String val = getString(key);
		return NumberUtil.parseInt(val, -1);
	}
	
	public static float getFloat(String key){
		String val = getString(key);
		return NumberUtil.parseFloat(val, -1f);
	}
	
	public static long getLong(String key){
		String val = getString(key);
		return NumberUtil.parseLong(val, -1l);
	}
}
